import numpy as np
from matplotlib import pyplot as plt

a = np.arange(12)
# print(a)
# print(a.ndim)  # a 现只有一个维度
# # 现在调整其大小
# b = a.reshape(2, 3, 4)  # b 现在拥有三个维度
# b = a.reshape(24, 1)
# print(b)

# a = np.array([[1,2,3], [4,5,6],[7,8,9]])
# print(a[a > 5])
# print(a[2])
# print(a[1,2])
# b = a[1:3, 1:3]
# c = a[1:3,[1,2]]
# d = a[1:,...]
# print(b)
# print(c)
# print(d)
# y = 2 * x + 5
# plt.title("Matplotlib demo")
# plt.xlabel("x axis caption")
# plt.ylabel("y axis caption")
# plt.plot(x, y)
# plt.show()
# x=np.arange(32).reshape((8,4))
# print(x)
# print('\n')
# # print (x[[4,2,1,7]])
# print(x[4,2])
# a = np.arange(6).reshape(2, 3)
# print('原始数组是：')
# print(a)
# print('\n')
# print('迭代输出元素：')
# for x in np.nditer(a):
#     print(x, end=", ")
# print('\n')
# a = np.array([0.25, 1.33, 1, 100])
# print('我们的数组是：')
# print(a)
# print('\n')
# print('调用 reciprocal 函数：')
# print(np.reciprocal(a))
# x = np.arange(9.).reshape(3, 3)
# print('我们的数组是：')
# print(x)
# # 定义条件, 选择偶数元素
# condition = np.mod(x, 2) == 0
# print('按元素的条件值：')
# print(condition)
# print('使用条件提取元素：')
# print(np.extract(condition, x))
# print('\n')
# print(np.extract((np.mod(x, 2) == 0), x))
# print('==============')
# y = np.where(x > 3)
# print(y)
# print(x[y])

# a = np.array([1, 2, 3, 4, 5])
#
# # 保存到 outfile.npy 文件上
# np.save('outfile.npy', a)
#
# # 保存到 outfile2.npy 文件上，如果文件路径末尾没有扩展名 .npy，该扩展名会被自动加上
# np.save('outfile2', a)
#
# b = np.load('outfile.npy')
# print(b)

# j = costFunctionJ(A, y, theta)
# % A is the
# "design matrix"
# containing
# our
# training
# examples
# % y is the
#
#
# class label


# m = size(A, 1); % number
# of
# training
# examples
# predictions = A * theta; % predictions
# of
# hypothesis
# on
# all
# m
# examples
# sqrErrors = (predictions - y). ^ 2; % square
# errors
#
# J = 1 / (2 * m) * sum(sqrErrors);




def logic(x):
    return 1 / (1 + np.exp(-x))




plt.plot(logic(3))
plt.show()

